<?php
include_once("inc/conn.php");
include_once("inc/function.php");
include_once("heheadmin/inc/config.php");
$id=intval($_GET['tj']);
if($id)setcookie('tj',$id);
if (empty($_COOKIE["usersid"]) || empty($_COOKIE["password"])){
    if(isset($_SESSION["usersid"]))
    {
        setcookie("usersid",$_SESSION["usersid"]);
        setcookie("username",$_SESSION["username"]);
        setcookie("password",$_SESSION["password"]);
    }
} else {
    if(!isset($_SESSION['usersid']))
    {
        $username = str_check($_COOKIE["username"]);
        $pwd = str_check($_COOKIE["password"]);
        
        $username = (strlen($username) > 50) ? substr($username,0,50) : $username;
        $pwd = (strlen($pwd) > 32) ? substr($pwd,0,32) : $pwd;
        
        $ip = usersip();
        $sql = "call web_user_login('{$username}','{$pwd}','{$ip}')";
        $arr = $db->Mysqli_Multi_Query($sql);
        if($arr[0][0]["result"] == '0'){
            $_SESSION["usersid"] = $arr[0][0]["userid"];
            $_SESSION["username"] = $arr[0][0]["username"];
            $_SESSION["nickname"] = $arr[0][0]["nickname"];
            $_SESSION["points"] = $arr[0][0]["points"];
            $_SESSION["bankpoints"] = $arr[0][0]["bankpoint"];
            $_SESSION["exp"] = $arr[0][0]["experience"]; 
            $_SESSION['freeze'] = 0;
        }
        else
        {
             unset($_SESSION['usersid']);
             session_destroy();    
        }
    }
    RefreshPoints();
    if(isset($_SESSION['freeze']) && $_SESSION['freeze'] == 1)
    {
        //退出
        session_destroy();
    }
}

 echo $_SESSION['vcode'];
?>
<!Doctype html>
<html lang="zh-cn">
<head>
    <title>保时捷28,蛋蛋28,加拿大28,幸运28,PC蛋蛋,<?php echo $web_name;?></title>
    <?php
    require 'public/title.inc_yj.php';
    ?>
    <link rel="stylesheet" type="text/css" href="style/yj_index.css" />
    <script type="text/javascript" src="js/login.js"></script>
</head>

<body>
<?php include_once("top2.php");?>
<div class="actCenter-section" style="min-height: 600px;">
        <div class="banner"></div>
        <div class="actTab mmc-section">
            <div class="header clearfix">
                <div class="item activeBtn active" id="tab_active" onclick="yj_change_tab('active')">正在进行的活动</div>
                <div class="item activeBtn" id="tab_unactive" onclick="yj_change_tab('unactive')">已经结束的活动</div>
            </div>
            <div class="act-section" id="active">
                    <?php
                        $_result = $db->query("SELECT tg_title,tg_img,tg_content,tg_start_time,tg_last_time FROM game_active WHERE tg_active = 1 ORDER BY tg_top DESC LIMIT 5");
                        $_html = array();
                        $i = 1;
                        while($rs = $db->fetch_array($_result)) {
                            $_html['title'] = $rs['tg_title'];
                            $_html['img'] = $rs['tg_img'];
                            $_html['content'] = $rs['tg_content'];
                            $_html['start_time'] = $rs['tg_start_time'];
                            $_html['last_time'] = $rs['tg_last_time'];
                    ?>
                        <div class="item">
                            <div class="act-header clearfix">
                                <div class="left fl" id="title"><?php echo $_html['title'];?></div>
                                <div class="right fr" id="activeTime">活动时间：<?php echo $_html['start_time'];?>至<?php echo $_html['last_time']; ?></div>
                            </div>
                            <div class="act-ctn clearfix">
                                <div class="left-img fl"><img class="actImg" src="<?php echo $_html['img']; ?>" alt="<?php echo $_html['title'];?>" id="activeImg"></div>
                                <div class="left-info fl">
                                    <div class="act-title strongColor" id="activeTitle"><?php echo $_html['title'];?></div>
                                    <div class="act-canJoin" id="activePerson">参加对象：所有认证会员</div>
                                    <a href="javascript:;" class="act-enterDetail" id="activeUrl" data-index="2">活动详情</a>
                                    <span class="yj_content" style="display: none;"><?php echo $_html['content']; ?></span>
                                </div>
                                <div class="right-info fr"></div>
                            </div>
                        </div>
                    <?php
                            $i++;
                        }
                    ?>
            </div>
            <div class="act-section" id="unactive" style="display: none;">
                <?php
                    $_result = $db->query("SELECT tg_title,tg_img,tg_content,tg_start_time,tg_last_time FROM game_active WHERE tg_active = 0 ORDER BY tg_top DESC LIMIT 5");
                    if (!$_reuslt){
                        echo '<div class="item" ><p style="text-align: center; padding:10px 0 0 0;">很抱歉,暂无此活动!</p></div>';
                    }

                    $_html = array();
                    $i = 100;
                    while($rs = $db->fetch_array($_result)) {
                        $_html['title'] = $rs['tg_title'];
                        $_html['img'] = $rs['tg_img'];
                        $_html['content'] = $rs['tg_content'];
                        $_html['start_time'] = $rs['tg_start_time'];
                        $_html['last_time'] = $rs['tg_last_time'];
                ?>
                    <div class="item" >
                        <div class="act-header clearfix">
                            <div class="left fl" id="title"><?php echo $_html['title'];?></div>
                            <div class="right fr" id="activeTime">活动时间：<?php echo $_html['start_time'];?>至<?php echo $_html['last_time']; ?></div>
                        </div>
                        <div class="act-ctn clearfix">
                            <div class="left-img fl"><img class="actImg" src="<?php echo $_html['img']; ?>" alt="<?php echo $_html['title'];?>" id="activeImg"></div>
                            <div class="left-info fl">
                                <div class="act-title strongColor" id="activeTitle"><?php echo $_html['title'];?></div>
                                <div class="act-canJoin" id="activePerson">参加对象：所有认证会员</div><a href="javascript:;" class="act-enterDetail" id="activeUrl" data-index="2">活动详情</a></div>
                            <div class="right-info fr"></div>
                        </div>
                    </div>
                <?php
                        $i++;
                    }
                ?>
            </div>
        </div>
        <div class="pagination mmc-section" style="display: none;">
            <div class="pageInfo">
                <div class="dataText fl"> 共<span class="allNum">1</span>记录，共<span class="pagesNum">4</span>页</div>
            </div>
            <div class="M-box"><a href="javascript:;" class="prev">上一页</a><span class="active">1</span><a href="javascript:;" class="next">下一页</a></div>
        </div>
    </div>
<?php
require 'yj_footer.php';
?>
<script type="text/javascript">
    function yj_change_tab(item_id){
        $('#active').css('display','none');
        $('#unactive').css('display','none');
        $('#tab_unactive').attr('class','item activeBtn');
        $('#tab_active').attr('class','item activeBtn');
        $('#'+item_id).css('display','block');
        $('#tab_'+item_id).attr('class','item activeBtn active');
    }
    $(".act-enterDetail").on("click", function() {
        var idx = $('.act-enterDetail').index($(this));
        var title = $('.act-title')[idx].innerHTML;
        var content = $('.yj_content')[idx].innerHTML;
        var dom = '<div class="msgModal">' + '<div class="msgtitle">' + title + '<span class="msgModalClose"></span></div>' + '<div class="msgcol1">' + content + "</div>" + "</div>";
        $("body").append(dom).css("overflow", "hidden");
        $(".msgModalClose").on("click", function() {
            $(".msgModal").remove();
            $("body").css("overflow", "auto")
        })
    })
</script>
    
</body>
</html>


